home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / info-service / gopher / Unix / xvgopher / v0.5beta / xvgopher.shar.02 < prev    next >
Encoding:
Text File  |  1993-03-26  |  49.1 KB  |  1,864 lines

  1. ---- Cut Here and feed the following to sh ----
  2. #!/bin/sh
  3. # This is part 02 of a multipart archive
  4. # ============= GWDownload.cc ==============
  5. if test -f 'GWDownload.cc' -a X"$1" != X"-c"; then
  6.     echo 'x - skipping GWDownload.cc (File already exists)'
  7. else
  8. echo 'x - extracting GWDownload.cc (Text)'
  9. sed 's/^X//' << 'SHAR_EOF' > 'GWDownload.cc' &&
  10. //
  11. // GWDownload.cc
  12. //
  13. // (c) Copyright 1993, San Diego State University -- College of Sciences
  14. //       (See the COPYRIGHT file for more Copyright information)
  15. //
  16. // Implementation of the GWDownload class
  17. //
  18. #include "GWDownload.h"
  19. #include "xvgopher.h"
  20. #include "cursor.h"
  21. #include <string.h>
  22. #include <fcntl.h>
  23. #include <unistd.h>
  24. X
  25. #define    KEY_TEXT_ITEM        20000
  26. #define    KEY_SAVE            20001
  27. #define    KEY_CANCEL            20002
  28. #define    KEY_OTHER            20003
  29. X
  30. X
  31. //***************************************************************************
  32. // GWDownload::GWDownload(Frame par, int download_type)
  33. //
  34. GWDownload::GWDownload(Frame par, int download_type)
  35. {
  36. X    parent = par;
  37. X    type = download_type;
  38. X    button = NULL;
  39. X    button_command = NULL;
  40. }
  41. X
  42. X
  43. //***************************************************************************
  44. // GWDownload::GWDownload(Frame par, int download_type, char  *btn, char *btncmd)
  45. //
  46. GWDownload::GWDownload(Frame par, int download_type, char  *btn, char *btncmd)
  47. {
  48. X    parent = par;
  49. X    type = download_type;
  50. X    button = btn;
  51. X    button_command = btncmd;
  52. }
  53. X
  54. X
  55. //***************************************************************************
  56. // void GWDownload::bin_save_notify(Panel_item item, Event *)
  57. // PURPOSE:
  58. //   We get here when the user wants to copy our temporary copy into a more
  59. //   permanent file.
  60. //
  61. void GWDownload::bin_save_notify(Panel_item item, Event *)
  62. {
  63. X    GWDownload    *gwindow = (GWDownload *) xv_get(item, XV_KEY_DATA, KEY_GWINDOW);
  64. X    Gopher        *gopher = gwindow->gopher;
  65. X    Panel_item    txt = (Panel_item) xv_get(item, XV_KEY_DATA, KEY_TEXT_ITEM);
  66. X    int    fd = ::open((char *) xv_get(txt, PANEL_VALUE), O_CREAT | O_WRONLY, 0644);
  67. X    if (fd < 0)
  68. X    {
  69. X        gwindow->status("Unable to create file");
  70. X        return;
  71. X    }
  72. X
  73. X    //
  74. X    // Ok, we now have a new file we can write to.  We will just open the
  75. X    // temporary file and copy its contents block by block to the new file.
  76. X    //
  77. X    gwindow->status("Saving...");
  78. X    int old = ::open(gopher->filename, O_RDONLY);
  79. X    char    buffer[10240];
  80. X    int        n;
  81. X    while ((n = ::read(old, buffer, 10240)) > 0)
  82. X    {
  83. X        ::write(fd, buffer, n);
  84. X    }
  85. X    ::close(fd);
  86. X    ::close(old);
  87. X    gwindow->status("File saved");
  88. }
  89. X
  90. X
  91. //***************************************************************************
  92. // void GWDownload::bin_cancel_notify(Panel_item, Event *)
  93. //
  94. void GWDownload::bin_cancel_notify(Panel_item item , Event *)
  95. {
  96. X    GWDownload    *gwindow = (GWDownload *) xv_get(item, XV_KEY_DATA, KEY_GWINDOW);
  97. X    delete gwindow;
  98. X    Frame    frame = (Frame) xv_get(item, XV_KEY_DATA, KEY_FRAME);
  99. X    xv_destroy_safe(frame);
  100. }
  101. X
  102. X
  103. //***************************************************************************
  104. // void GWDownload::bin_other_notify(Panel_item, Event *)
  105. //
  106. void GWDownload::bin_other_notify(Panel_item item , Event *)
  107. {
  108. X    GWDownload    *gwindow = (GWDownload *) xv_get(item, XV_KEY_DATA, KEY_GWINDOW);
  109. X    Gopher        *gopher = gwindow->gopher;
  110. X    Panel_item    txt = (Panel_item) xv_get(item, XV_KEY_DATA, KEY_TEXT_ITEM);
  111. X
  112. X    char        command[1000];
  113. X    sprintf(command, "%s %s &", gwindow->button_command, gopher->filename);
  114. X    system(command);
  115. X
  116. X    sprintf(command, "Started %s on %s", gwindow->button, gopher->filename);
  117. X    gwindow->status(command);
  118. }
  119. X
  120. X
  121. //***************************************************************************
  122. // Panel_setting GWDownload::bin_text_notify(Panel_item item, Event *event)
  123. //
  124. Panel_setting GWDownload::bin_text_notify(Panel_item item, Event *event)
  125. {
  126. X    bin_save_notify(item, event);
  127. X    return PANEL_NONE;
  128. }
  129. X
  130. X
  131. //***************************************************************************
  132. // int GWDownload::open(Response *resp)
  133. // PURPOSE:
  134. // This will create a prompt window
  135. //
  136. int GWDownload::open(Response *resp)
  137. {
  138. X    info = resp;
  139. X    compute_location(407, 107);
  140. X    frame = (Frame) xv_create(parent, FRAME_CMD,
  141. X        XV_X,                            next_x,
  142. X        XV_Y,                            next_y,
  143. X        XV_WIDTH,                        407,
  144. X        XV_HEIGHT,                        107,
  145. X        FRAME_LABEL,                    "Saving a file",
  146. X        FRAME_CMD_PIN_STATE,            FRAME_CMD_PIN_IN,
  147. X        FRAME_SHOW_RESIZE_CORNER,        FALSE,
  148. X        XV_SHOW,                        TRUE,
  149. X        FRAME_SHOW_FOOTER,                TRUE,
  150. X        FRAME_RIGHT_FOOTER,                info->get_server(),
  151. X        FRAME_DONE_PROC,                done_proc,
  152. X        FRAME_ACCELERATOR,                'q', quit_proc, frame,
  153. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  154. X        NULL);
  155. X    panel = (Panel) xv_get(frame, FRAME_CMD_PANEL);
  156. X
  157. X    //
  158. X    // Create the text field and put a usable default name in it.
  159. X    //
  160. X    char    *p = strrchr(info->get_command(), '/');
  161. X    if (!p)
  162. X        p = info->get_command();
  163. X    else
  164. X        p++;
  165. X    char    *str = strdup(p);
  166. X    for (p = str; *p; p++)
  167. X        if (*p <= ' ' || *p > 126)
  168. X            *p = '_';
  169. X    Panel_item txt = (Panel_item) xv_create(panel, PANEL_TEXT,
  170. X        XV_X,                            16,
  171. X        XV_Y,                            28,
  172. X        PANEL_LABEL_STRING,                "Save file as:",
  173. X        PANEL_VALUE_DISPLAY_LENGTH,        35,
  174. X        PANEL_VALUE_STORED_LENGTH,        80,
  175. X        PANEL_VALUE,                    str,
  176. X        PANEL_NOTIFY_PROC,                bin_text_notify,
  177. X        XV_KEY_DATA,                    KEY_FRAME,        frame,
  178. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  179. X        XV_KEY_DATA,                    KEY_GOPHER,        gopher,
  180. X        PANEL_INACTIVE,                    TRUE,
  181. X        NULL);
  182. X    delete str;
  183. X    xv_set(txt,
  184. X        XV_KEY_DATA,                    KEY_TEXT_ITEM,    txt,
  185. X        NULL);
  186. X
  187. X    //
  188. X    // Create the buttons.  There may be two or three buttons.  We need to spread them
  189. X    // evenly to make it look better.
  190. X    //
  191. X    int        ob_x, sb_x, cb_x;
  192. X    if (button)
  193. X    {
  194. X        //
  195. X        // There will be three buttons
  196. X        //
  197. X        ob_x = 107;
  198. X        sb_x = 175;
  199. X        cb_x = 241;
  200. X    }
  201. X    else
  202. X    {
  203. X        //
  204. X        // Only two buttons
  205. X        //
  206. X        sb_x = 141;
  207. X        cb_x = 207;
  208. X    }
  209. X    Panel_item sb = (Panel_item) xv_create(panel, PANEL_BUTTON,
  210. X        XV_X,                            sb_x,
  211. X        XV_Y,                            64,
  212. X        PANEL_LABEL_STRING,                "Save",
  213. X        PANEL_NOTIFY_PROC,                bin_save_notify,
  214. X        XV_KEY_DATA,                    KEY_FRAME,        frame,
  215. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  216. X        XV_KEY_DATA,                    KEY_GOPHER,        gopher,
  217. X        XV_KEY_DATA,                    KEY_TEXT_ITEM,    txt,
  218. X        PANEL_INACTIVE,                    TRUE,
  219. X        NULL);
  220. X    Panel_item cb = (Panel_item) xv_create(panel, PANEL_BUTTON,
  221. X        XV_X,                            cb_x,
  222. X        XV_Y,                            64,
  223. X        PANEL_LABEL_STRING,                "Cancel",
  224. X        PANEL_NOTIFY_PROC,                bin_cancel_notify,
  225. X        XV_KEY_DATA,                    KEY_FRAME,        frame,
  226. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  227. X        XV_KEY_DATA,                    KEY_TEXT_ITEM,    txt,
  228. X        PANEL_INACTIVE,                    TRUE,
  229. X        NULL);
  230. X    Panel_item    ob = NULL;
  231. X    if (button)
  232. X    {
  233. X        ob = (Panel_item) xv_create(panel, PANEL_BUTTON,
  234. X            XV_X,                            ob_x,
  235. X            XV_Y,                            64,
  236. X            PANEL_LABEL_STRING,                button,
  237. X            PANEL_NOTIFY_PROC,                bin_other_notify,
  238. X            XV_KEY_DATA,                    KEY_FRAME,        frame,
  239. X            XV_KEY_DATA,                    KEY_GWINDOW,    this,
  240. X            XV_KEY_DATA,                    KEY_TEXT_ITEM,    txt,
  241. X            PANEL_INACTIVE,                    TRUE,
  242. X            NULL);
  243. X    }
  244. X
  245. X    //
  246. X    // Associate the panel items with the frame so we can get at them later on
  247. X    //
  248. X    xv_set(frame,
  249. X        XV_KEY_DATA,                    KEY_SAVE,        sb,
  250. X        XV_KEY_DATA,                    KEY_CANCEL,        cb,
  251. X        XV_KEY_DATA,                    KEY_OTHER,        ob,
  252. X        XV_KEY_DATA,                    KEY_TEXT_ITEM,    txt,
  253. X        NULL);
  254. X    //
  255. X    // Now we need to build the connection and get information from it
  256. X    //
  257. X    frame_busy(frame);
  258. X    status("Building connection...");
  259. X    gopher = new Gopher(this);
  260. X    if (gopher->open(info->get_server(), info->get_port()) == NOTOK)        // Connection
  261. X        return NOTOK;
  262. X    gopher->read(info->get_type(), info->get_command());                    // Get info
  263. X
  264. X    return OK;
  265. }
  266. X
  267. X
  268. //***************************************************************************
  269. // void GWDownload::display()
  270. // PURPOSE:
  271. //   This is called when the receive of a file has been completed.
  272. //
  273. void GWDownload::display()
  274. {
  275. X    //
  276. X    // Now make the items in the window active so that the file can be saved
  277. X    //
  278. X    frame_unbusy(frame);
  279. X    Panel_item    b = (Panel_item) xv_get(frame, XV_KEY_DATA, KEY_SAVE);
  280. X    xv_set(b, PANEL_INACTIVE, FALSE, NULL);
  281. X    b = (Panel_item) xv_get(frame, XV_KEY_DATA, KEY_CANCEL);
  282. X    xv_set(b, PANEL_INACTIVE, FALSE, NULL);
  283. X    b = (Panel_item) xv_get(frame, XV_KEY_DATA, KEY_TEXT_ITEM);
  284. X    xv_set(b, PANEL_INACTIVE, FALSE, NULL);
  285. X    b = (Panel_item) xv_get(frame, XV_KEY_DATA, KEY_OTHER);
  286. X    if (b)
  287. X        xv_set(b, PANEL_INACTIVE, FALSE, NULL);
  288. }
  289. X
  290. X
  291. SHAR_EOF
  292. chmod 0644 GWDownload.cc ||
  293. echo 'restore of GWDownload.cc failed'
  294. Wc_c="`wc -c < 'GWDownload.cc'`"
  295. test 7644 -eq "$Wc_c" ||
  296.     echo 'GWDownload.cc: original size 7644, current size' "$Wc_c"
  297. fi
  298. # ============= GWFile.cc ==============
  299. if test -f 'GWFile.cc' -a X"$1" != X"-c"; then
  300.     echo 'x - skipping GWFile.cc (File already exists)'
  301. else
  302. echo 'x - extracting GWFile.cc (Text)'
  303. sed 's/^X//' << 'SHAR_EOF' > 'GWFile.cc' &&
  304. //
  305. // GWFile.cc
  306. //
  307. // (c) Copyright 1993, San Diego State University -- College of Sciences
  308. //       (See the COPYRIGHT file for more Copyright information)
  309. //
  310. // Implementation of the GWFile class
  311. //
  312. #include "GWFile.h"
  313. #include "xvgopher.h"
  314. #include "cursor.h"
  315. #include <xview/textsw.h>
  316. X
  317. #define    KEY_TEXT_ITEM        20000
  318. #define    KEY_TYPE            20001
  319. #define    KEY_TEXT            20002
  320. #define    TYPE_SAVE            1
  321. #define    TYPE_MAIL            2
  322. X
  323. X
  324. //***************************************************************************
  325. // GWFile::GWFile(Frame par)
  326. //
  327. GWFile::GWFile(Frame par)
  328. {
  329. X    parent = par;
  330. }
  331. X
  332. X
  333. //***************************************************************************
  334. // static void menu_proc(Menu menu, Menu_item menu_item)
  335. //
  336. static void menu_proc(Menu menu, Menu_item menu_item)
  337. {
  338. X    char        *str = (char *) xv_get(menu_item, MENU_STRING);
  339. X    Panel_item    txt = (Panel_item) xv_get(menu, XV_KEY_DATA, KEY_TEXT_ITEM);
  340. X    Textsw    t = (Textsw) xv_get(menu, XV_KEY_DATA, KEY_TEXT);
  341. X    char        command[200];
  342. X
  343. X    if (strcmp(str, "Save...") == 0)
  344. X    {
  345. X        xv_set(txt,
  346. X            PANEL_LABEL_STRING,        "Save as:",
  347. X            XV_KEY_DATA,            KEY_TYPE,        TYPE_SAVE,
  348. X            XV_SHOW,                TRUE,
  349. X            NULL);
  350. X    }
  351. X    else if (strcmp(str, "Print") == 0)
  352. X    {
  353. X        //
  354. X        // First save the file
  355. X        //
  356. X        textsw_save(t, 0, 0);
  357. X        char name[200];
  358. X        name[0] = '\0';
  359. X        textsw_append_file_name(t, name);
  360. X
  361. X        //
  362. X        // This needs to use a user definable print method!!!
  363. X        //
  364. X        sprintf(command, "%s %s &", preferences.get_print_filter(), name);
  365. X        system(command);
  366. X    }
  367. X    else if (strcmp(str, "Mail...") == 0)
  368. X    {
  369. X        xv_set(txt,
  370. X            PANEL_LABEL_STRING,        "Mail to:",
  371. X            XV_KEY_DATA,            KEY_TYPE,        TYPE_MAIL,
  372. X            XV_SHOW,                TRUE,
  373. X            NULL);
  374. X    }
  375. }
  376. X
  377. X
  378. //***************************************************************************
  379. // static Panel_setting text_notify(Panel_item item, Event *event)
  380. //
  381. static Panel_setting text_notify(Panel_item item, Event *event)
  382. {
  383. X    event = event;
  384. X    char    *string = (char *) xv_get(item, PANEL_VALUE);
  385. X    Textsw    t = (Textsw) xv_get(item, XV_KEY_DATA, KEY_TEXT);
  386. X    GWindow    *gwindow = (GWindow *) xv_get(item, XV_KEY_DATA, KEY_GWINDOW);
  387. X
  388. X    switch (xv_get(item, XV_KEY_DATA, KEY_TYPE))
  389. X    {
  390. X        case TYPE_SAVE:
  391. X            gwindow->status("Saving...");
  392. X            if (textsw_store_file(t, string, 0, 0) != 0)
  393. X            {
  394. X                //
  395. X                // Some problem occured...  Notify the user
  396. X                //
  397. X                gwindow->status("Unable to save!");
  398. X            }
  399. X            else
  400. X                gwindow->status("File saved");
  401. X            break;
  402. X        case TYPE_MAIL:
  403. X        {
  404. X            textsw_save(t, 0, 0);
  405. X            char name[200];
  406. X            name[0] = '\0';
  407. X
  408. X            Frame    frame = (Frame) xv_get(item, XV_KEY_DATA, KEY_FRAME);
  409. X            char    *subject = (char *) xv_get(frame, FRAME_LABEL);
  410. X
  411. X            textsw_append_file_name(t, name);
  412. X            gwindow->status("Mailing...");
  413. X            char    command[200];
  414. X            sprintf(command, "%s -s '%s' %s < %s", preferences.get_mail_filter(), subject, string, name);
  415. X            system(command);
  416. X            gwindow->status("File mailed");
  417. X            break;
  418. X        }
  419. X    }
  420. X    return PANEL_NONE;
  421. }
  422. X
  423. X
  424. //***************************************************************************
  425. // int GWFile::open(Response *resp)
  426. // PURPOSE:
  427. //   This will create a window in which a file will be displayed.  We will create
  428. //   a command frame with a textsw at the bottom.  The top will be a panel with
  429. //   a menu and a hidden text field.
  430. //
  431. int GWFile::open(Response *resp)
  432. {
  433. X    info = resp;
  434. X    compute_location(600, 500);
  435. X    frame = (Frame) xv_create(parent, FRAME_CMD,
  436. X        XV_X,                            next_x,
  437. X        XV_Y,                            next_y,
  438. X        XV_WIDTH,                        600,
  439. X        XV_HEIGHT,                        500,
  440. X        FRAME_LABEL,                    info->get_title(),
  441. X        FRAME_CMD_PIN_STATE,            FRAME_CMD_PIN_IN,
  442. X        FRAME_SHOW_RESIZE_CORNER,        TRUE,
  443. X        XV_SHOW,                        TRUE,
  444. X        FRAME_SHOW_FOOTER,                TRUE,
  445. X        FRAME_RIGHT_FOOTER,                info->get_server(),
  446. X        FRAME_DONE_PROC,                done_proc,
  447. X        FRAME_ACCELERATOR,                'q', quit_proc, frame,
  448. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  449. X        NULL);
  450. X    panel = (Panel) xv_get(frame, FRAME_CMD_PANEL);
  451. X    textsw = (Textsw) xv_create(frame, TEXTSW,
  452. X        XV_X,                        0,
  453. X        XV_Y,                        29,
  454. X        NULL);
  455. X
  456. X    //
  457. X    // Child windows have a close button
  458. X    //
  459. X    dir_quit = xv_create(panel, PANEL_BUTTON,
  460. X        XV_X,                        488,    // It will be relocated anyway...
  461. X        XV_Y,                        4,
  462. X        PANEL_LABEL_STRING,            "Dismiss",
  463. X        PANEL_NOTIFY_PROC,            quit_proc,
  464. X        XV_KEY_DATA,                KEY_GWINDOW, this,
  465. X        NULL);
  466. X
  467. X    //
  468. X    // Create the menu and button which go in the panel...
  469. X    //
  470. X    Menu menu = (Menu) xv_create(NULL, MENU,
  471. X        MENU_NOTIFY_PROC,                menu_proc,
  472. X        MENU_STRINGS,                    "Save...",
  473. X                                        "Print",
  474. X                                        "Mail...",
  475. X                                        NULL,
  476. X        NULL);
  477. X    xv_create(panel, PANEL_BUTTON,
  478. X        XV_X,                            8,
  479. X        XV_Y,                            4,
  480. X        PANEL_LABEL_STRING,                "Options",
  481. X        PANEL_ITEM_MENU,                menu,
  482. X        NULL);
  483. X
  484. X    //
  485. X    // Create the text item (which will not be visible until one of the options has been
  486. X    // selected)
  487. X    //
  488. X    Panel_item txt = (Panel_item) xv_create(panel, PANEL_TEXT,
  489. X        XV_X,                            128,
  490. X        XV_Y,                            8,
  491. X        PANEL_LABEL_STRING,                "",
  492. X        PANEL_VALUE_DISPLAY_LENGTH,        40,
  493. X        PANEL_VALUE_STORED_LENGTH,        80,
  494. X        PANEL_NOTIFY_PROC,                text_notify,
  495. X        XV_SHOW,                        FALSE,            // Invisible, initially
  496. X        XV_KEY_DATA,                    KEY_FRAME,        frame,
  497. X        XV_KEY_DATA,                    KEY_TEXT,        textsw,
  498. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  499. X        NULL);
  500. X
  501. X    //
  502. X    // Attach the Frame to the menu so that we can see where we were created
  503. X    // when a menu option was selected.
  504. X    //
  505. X    xv_set(menu,
  506. X        XV_KEY_DATA,                    KEY_FRAME,        frame,
  507. X        XV_KEY_DATA,                    KEY_TEXT_ITEM,    txt,
  508. X        XV_KEY_DATA,                    KEY_TEXT,        textsw,
  509. X        NULL);
  510. X
  511. X    //
  512. X    // Now we need to build the connection and get information from it
  513. X    //
  514. X    frame_busy(frame);
  515. X    gopher = new Gopher(this);
  516. X    if (gopher->open(info->get_server(), info->get_port()) == NOTOK)        // Connection
  517. X        return NOTOK;
  518. X    status("Got connection, Retrieving text...");
  519. X    gopher->read(info->get_type(), info->get_command());                    // Get info
  520. X
  521. X    return OK;
  522. }
  523. X
  524. X
  525. //***************************************************************************
  526. // void GWFile::display()
  527. //
  528. void GWFile::display()
  529. {
  530. X    frame_unbusy(frame);
  531. X    xv_set(textsw,
  532. X        TEXTSW_FILE,            gopher->filename,
  533. X        NULL);
  534. }
  535. X
  536. X
  537. SHAR_EOF
  538. chmod 0664 GWFile.cc ||
  539. echo 'restore of GWFile.cc failed'
  540. Wc_c="`wc -c < 'GWFile.cc'`"
  541. test 5861 -eq "$Wc_c" ||
  542.     echo 'GWFile.cc: original size 5861, current size' "$Wc_c"
  543. fi
  544. # ============= GWGopher.cc ==============
  545. if test -f 'GWGopher.cc' -a X"$1" != X"-c"; then
  546.     echo 'x - skipping GWGopher.cc (File already exists)'
  547. else
  548. echo 'x - extracting GWGopher.cc (Text)'
  549. sed 's/^X//' << 'SHAR_EOF' > 'GWGopher.cc' &&
  550. //
  551. // GWGopher.cc
  552. //
  553. // (c) Copyright 1993, San Diego State University -- College of Sciences
  554. //       (See the COPYRIGHT file for more Copyright information)
  555. //
  556. // Implementation of the GWGopher class
  557. //
  558. #include "GWGopher.h"
  559. #include "xvgopher.h"
  560. #include "cursor.h"
  561. #include <fcntl.h>
  562. #include <unistd.h>
  563. X
  564. #define    KEY_TEXT_ITEM        20000
  565. X
  566. X
  567. //***************************************************************************
  568. // GWGopher::GWGopher(Frame par)
  569. //
  570. GWGopher::GWGopher(Frame par)
  571. {
  572. X    parent = par;
  573. }
  574. X
  575. X
  576. //***************************************************************************
  577. // int GWGopher::open(Response *)
  578. // PURPOSE:
  579. //   This will create a dialog window to get information about a new gopher server
  580. //
  581. int GWGopher::open(Response *)
  582. {
  583. X    info = NULL;
  584. X    compute_location(407, 107);
  585. X    frame = (Frame) xv_create(parent, FRAME_CMD,
  586. X        XV_X,                            next_x,
  587. X        XV_Y,                            next_y,
  588. X        XV_WIDTH,                        416,
  589. X        XV_HEIGHT,                        128,
  590. X        FRAME_LABEL,                    "Another Gopher",
  591. X        FRAME_CMD_PIN_STATE,            FRAME_CMD_PIN_OUT,
  592. X        FRAME_SHOW_RESIZE_CORNER,        FALSE,
  593. X        XV_SHOW,                        TRUE,
  594. X        FRAME_SHOW_FOOTER,                FALSE,
  595. X        FRAME_DONE_PROC,                done_proc,
  596. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  597. X        NULL);
  598. X    panel = (Panel) xv_get(frame, FRAME_CMD_PANEL);
  599. X
  600. X    //
  601. X    // Create all the panel items
  602. X    //
  603. X    server = (Panel_item) xv_create(panel, PANEL_TEXT,
  604. X        XV_X,                            32,
  605. X        XV_Y,                            16,
  606. X        PANEL_LABEL_STRING,                "Server name:",
  607. X        PANEL_VALUE_DISPLAY_LENGTH,        30,
  608. X        PANEL_VALUE_STORED_LENGTH,        80,
  609. X        NULL);
  610. X    port = (Panel_item) xv_create(panel, PANEL_NUMERIC_TEXT,
  611. X        XV_X,                            43,
  612. X        XV_Y,                            41,
  613. X        PANEL_LABEL_STRING,                "Server port:",
  614. X        PANEL_VALUE_DISPLAY_LENGTH,        5,
  615. X        PANEL_VALUE_STORED_LENGTH,        80,
  616. X        PANEL_MAX_VALUE,                30000,
  617. X        PANEL_MIN_VALUE,                1,
  618. X        PANEL_VALUE,                    70,
  619. X        NULL);
  620. X    xv_create(panel, PANEL_BUTTON,
  621. X        XV_X,                            185,
  622. X        XV_Y,                            88,
  623. X        PANEL_LABEL_STRING,                "Start",
  624. X        PANEL_NOTIFY_PROC,                start_proc,
  625. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  626. X        NULL);
  627. X    return OK;
  628. }
  629. X
  630. X
  631. //***************************************************************************
  632. // void GWGopher::start_proc(Frame frame, Event *)
  633. // PURPOS:
  634. //   This gets called when the user presses 'q' in a window.
  635. //
  636. void GWGopher::start_proc(Frame frame, Event *)
  637. {
  638. X    GWGopher    *win = (GWGopher *) xv_get(frame, XV_KEY_DATA, KEY_GWINDOW);
  639. X
  640. X    int port = (int) xv_get(win->port, PANEL_VALUE);
  641. X    char *server = (char *) xv_get(win->server, PANEL_VALUE);
  642. X
  643. X    Response    *r = new Response("1");
  644. X    r->set_server(server);
  645. X    r->set_port(port);
  646. X    GWindow    *main_window = CreateWindow(r, win->frame);
  647. X    if (main_window)
  648. X        main_window->open(r);
  649. X
  650. X    xv_destroy_safe(frame);
  651. }
  652. X
  653. X
  654. SHAR_EOF
  655. chmod 0664 GWGopher.cc ||
  656. echo 'restore of GWGopher.cc failed'
  657. Wc_c="`wc -c < 'GWGopher.cc'`"
  658. test 2602 -eq "$Wc_c" ||
  659.     echo 'GWGopher.cc: original size 2602, current size' "$Wc_c"
  660. fi
  661. # ============= GWImage.cc ==============
  662. if test -f 'GWImage.cc' -a X"$1" != X"-c"; then
  663.     echo 'x - skipping GWImage.cc (File already exists)'
  664. else
  665. echo 'x - extracting GWImage.cc (Text)'
  666. sed 's/^X//' << 'SHAR_EOF' > 'GWImage.cc' &&
  667. //
  668. // GWImage.cc
  669. //
  670. // (c) Copyright 1993, San Diego State University -- College of Sciences
  671. //       (See the COPYRIGHT file for more Copyright information)
  672. //
  673. // Implementation of the GWImage class
  674. //
  675. #include "GWImage.h"
  676. #include "xvgopher.h"
  677. X
  678. X
  679. //***************************************************************************
  680. // GWImage::GWImage(Frame par)
  681. //
  682. GWImage::GWImage(Frame par) : GWDownload(par, GWDownload::BINARY, "View", preferences.get_image_filter())
  683. {
  684. }
  685. X
  686. X
  687. SHAR_EOF
  688. chmod 0644 GWImage.cc ||
  689. echo 'restore of GWImage.cc failed'
  690. Wc_c="`wc -c < 'GWImage.cc'`"
  691. test 472 -eq "$Wc_c" ||
  692.     echo 'GWImage.cc: original size 472, current size' "$Wc_c"
  693. fi
  694. # ============= GWIndex.cc ==============
  695. if test -f 'GWIndex.cc' -a X"$1" != X"-c"; then
  696.     echo 'x - skipping GWIndex.cc (File already exists)'
  697. else
  698. echo 'x - extracting GWIndex.cc (Text)'
  699. sed 's/^X//' << 'SHAR_EOF' > 'GWIndex.cc' &&
  700. //
  701. // GWIndex.cc
  702. //
  703. // (c) Copyright 1993, San Diego State University -- College of Sciences
  704. //       (See the COPYRIGHT file for more Copyright information)
  705. //
  706. // Implementation of the GWIndex class
  707. //
  708. #include "GWIndex.h"
  709. #include "xvgopher.h"
  710. #include "cursor.h"
  711. #include <fcntl.h>
  712. #include <unistd.h>
  713. X
  714. #define    KEY_TEXT_ITEM        20000
  715. X
  716. X
  717. //***************************************************************************
  718. // GWIndex::GWIndex(Frame par)
  719. //
  720. GWIndex::GWIndex(Frame par)
  721. {
  722. X    parent = par;
  723. }
  724. X
  725. X
  726. //***************************************************************************
  727. // Panel_setting GWIndex::index_notify(Panel_item item, Event *event)
  728. // PURPOSE:
  729. //   This is called whenever the user hits return on the text field.
  730. //   When this happens, we will use the string to send to the server
  731. //   and then we can wait for the server to send us the results of the
  732. //   search.
  733. //
  734. Panel_setting GWIndex::index_notify(Panel_item item, Event *event)
  735. {
  736. X    event = event;
  737. X    //
  738. X    // We need to build the connection and get information from it
  739. X    //
  740. X    GWIndex    *gwindow = (GWIndex *) xv_get(item, XV_KEY_DATA, KEY_GWINDOW);
  741. X
  742. X    gwindow->status("Performing search...");
  743. X
  744. X    //
  745. X    // Build a new command string to send to the server.  This means that we just add
  746. X    // a tab and the string in our text field to the command.
  747. X    //
  748. X    char    new_command[10000];
  749. X
  750. X    Response    *r = new Response("1Results of search");
  751. X    r->set_server(gwindow->info->get_server());
  752. X    r->set_port(gwindow->info->get_port());
  753. X    sprintf(new_command, "%s\t%s",
  754. X                gwindow->info->get_command(),
  755. X                (char *) xv_get(item, PANEL_VALUE));
  756. X    r->set_command(new_command);
  757. X    GWindow *sub = CreateWindow(r, gwindow->frame);
  758. X
  759. X    gwindow->status("");
  760. X    return PANEL_NONE;
  761. }
  762. X
  763. X
  764. //***************************************************************************
  765. // int GWIndex::open(Response *resp)
  766. // PURPOSE:
  767. //   This will create a prompt window
  768. //
  769. int GWIndex::open(Response *resp)
  770. {
  771. X    info = resp;
  772. X    char    frame_title[2000];
  773. X    sprintf(frame_title, "Index search: %s", info->get_title());
  774. X    compute_location(407, 107);
  775. X    frame = (Frame) xv_create(parent, FRAME_CMD,
  776. X        XV_X,                            next_x,
  777. X        XV_Y,                            next_y,
  778. X        XV_WIDTH,                        407,
  779. X        XV_HEIGHT,                        107,
  780. X        FRAME_LABEL,                    frame_title,
  781. X        FRAME_CMD_PIN_STATE,            FRAME_CMD_PIN_IN,
  782. X        FRAME_SHOW_RESIZE_CORNER,        FALSE,
  783. X        XV_SHOW,                        TRUE,
  784. X        FRAME_SHOW_FOOTER,                TRUE,
  785. X        FRAME_RIGHT_FOOTER,                info->get_server(),
  786. X        FRAME_DONE_PROC,                done_proc,
  787. X        FRAME_ACCELERATOR,                'q', quit_proc, frame,
  788. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  789. X        NULL);
  790. X    panel = (Panel) xv_get(frame, FRAME_CMD_PANEL);
  791. X
  792. X    (Panel_item) xv_create(panel, PANEL_TEXT,
  793. X        XV_X,                            16,
  794. X        XV_Y,                            28,
  795. X        PANEL_LABEL_STRING,                "Search for:",
  796. X        PANEL_VALUE_DISPLAY_LENGTH,        35,
  797. X        PANEL_VALUE_STORED_LENGTH,        80,
  798. X        PANEL_NOTIFY_PROC,                index_notify,
  799. X        XV_KEY_DATA,                    KEY_FRAME,        frame,
  800. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  801. X        XV_KEY_DATA,                    KEY_GOPHER,        gopher,
  802. X        NULL);
  803. X
  804. X    return OK;
  805. }
  806. X
  807. SHAR_EOF
  808. chmod 0644 GWIndex.cc ||
  809. echo 'restore of GWIndex.cc failed'
  810. Wc_c="`wc -c < 'GWIndex.cc'`"
  811. test 2924 -eq "$Wc_c" ||
  812.     echo 'GWIndex.cc: original size 2924, current size' "$Wc_c"
  813. fi
  814. # ============= GWInfo.cc ==============
  815. if test -f 'GWInfo.cc' -a X"$1" != X"-c"; then
  816.     echo 'x - skipping GWInfo.cc (File already exists)'
  817. else
  818. echo 'x - extracting GWInfo.cc (Text)'
  819. sed 's/^X//' << 'SHAR_EOF' > 'GWInfo.cc' &&
  820. //
  821. // GWInfo.cc
  822. //
  823. // (c) Copyright 1993, San Diego State University -- College of Sciences
  824. //       (See the COPYRIGHT file for more Copyright information)
  825. //
  826. // Implementation of the GWInfo class
  827. //
  828. #include "GWInfo.h"
  829. X
  830. //***************************************************************************
  831. // GWInfo::GWInfo(Frame par)
  832. //
  833. GWInfo::GWInfo(Frame par)
  834. {
  835. X    parent = par;
  836. }
  837. X
  838. X
  839. //***************************************************************************
  840. // int GWInfo::open(Response *resp)
  841. //   Create a little popup which contains information about a response.
  842. //
  843. int GWInfo::open(Response *resp)
  844. {
  845. X    info = resp;
  846. X    char    frame_title[2000];
  847. X    sprintf(frame_title, "Info for '%s'", info->get_title());
  848. X    compute_location(390, 180);
  849. X    frame = (Frame) xv_create(parent, FRAME_CMD,
  850. X        XV_X,                            next_x,
  851. X        XV_Y,                            next_y,
  852. X        XV_WIDTH,                        390,
  853. X        XV_HEIGHT,                        180,
  854. X        FRAME_LABEL,                    frame_title,
  855. X        FRAME_CMD_PIN_STATE,            FRAME_CMD_PIN_IN,
  856. X        FRAME_SHOW_RESIZE_CORNER,        FALSE,
  857. X        XV_SHOW,                        TRUE,
  858. X        FRAME_DONE_PROC,                done_proc,
  859. X        FRAME_ACCELERATOR,                'q', quit_proc, frame,
  860. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  861. X        NULL);
  862. X    panel = (Panel) xv_get(frame, FRAME_CMD_PANEL);
  863. X
  864. X    //
  865. X    // Create the textsw in the window with the text describing the item.
  866. X    //
  867. X    char    buffer[10240];
  868. X    sprintf(buffer, "Name=%s\nType=%c\nPort=%d\nPath=%s\nHost=%s\n",
  869. X        info->get_title(),
  870. X        info->get_type(),
  871. X        info->get_port(),
  872. X        info->get_command(),
  873. X        info->get_server());
  874. X    xv_create(frame, TEXTSW,
  875. X        XV_X,                            0,
  876. X        XV_Y,                            0,
  877. X        XV_WIDTH,                        390,
  878. X        XV_HEIGHT,                        180,
  879. X        TEXTSW_CONTENTS,                buffer,
  880. X        TEXTSW_IGNORE_LIMIT,            TEXTSW_INFINITY,
  881. X        TEXTSW_READ_ONLY,                TRUE,
  882. X        NULL);
  883. X
  884. X    return OK;
  885. }
  886. X
  887. SHAR_EOF
  888. chmod 0644 GWInfo.cc ||
  889. echo 'restore of GWInfo.cc failed'
  890. Wc_c="`wc -c < 'GWInfo.cc'`"
  891. test 1679 -eq "$Wc_c" ||
  892.     echo 'GWInfo.cc: original size 1679, current size' "$Wc_c"
  893. fi
  894. # ============= GWList.cc ==============
  895. if test -f 'GWList.cc' -a X"$1" != X"-c"; then
  896.     echo 'x - skipping GWList.cc (File already exists)'
  897. else
  898. echo 'x - extracting GWList.cc (Text)'
  899. sed 's/^X//' << 'SHAR_EOF' > 'GWList.cc' &&
  900. //
  901. // GWList.cc
  902. //
  903. // (c) Copyright 1993, San Diego State University -- College of Sciences
  904. //       (See the COPYRIGHT file for more Copyright information)
  905. //
  906. //   This  file  contains  the  routines  of the GWList class which
  907. //   deal with the opening of windows.
  908. //
  909. #include "GWList.h"
  910. #include "xvgopher.h"
  911. #include "cursor.h"
  912. #include "icons.h"
  913. #include "GWBookmarks.h"
  914. #include "GWInfo.h"
  915. #include <stream.h>
  916. #include <string.h>
  917. #include <xview/svrimage.h>
  918. #include <xview/icon.h>
  919. #include <xview/defaults.h>
  920. X
  921. X
  922. static long    double_click_timeout = defaults_get_integer("openwindows.multiclicktimeout", "OpenWindows.MultiClickTimeout", 4) * 100;
  923. X
  924. //***************************************************************************
  925. // GWList::GWList()
  926. //   Do generic initialization.  This should be called from any derived constructor.
  927. //
  928. GWList::GWList()
  929. {
  930. X    parent = NULL;
  931. X    dir_list = NULL;
  932. X    dir_quit = NULL;
  933. X    current_selected = -1;
  934. }
  935. X
  936. X
  937. //***************************************************************************
  938. // void GWList::frame_event(Xv_Window window, Event *event, Notify_arg)
  939. //   This is where we will take care of window resize events.  This is rather
  940. //   messy because XView does not allow for arbitrarily sized scrolling lists.
  941. //   Instead we have to specify the height in rows, not in pixels like the width
  942. //
  943. void GWList::frame_event(Xv_Window window, Event *event, Notify_arg)
  944. {
  945. X    if (event_action(event) == WIN_RESIZE)
  946. X    {
  947. X        //
  948. X        //   The  window  has  been  resized. We need to resize the list and
  949. X        //   relocate the quit button.
  950. X        //
  951. X        GWList *gwindow = (GWList *) xv_get(window, XV_KEY_DATA, KEY_GWINDOW);
  952. X        int width = (int) xv_get(window, XV_WIDTH);
  953. X        int height = (int) xv_get(window, XV_HEIGHT);
  954. X
  955. X        //
  956. X        //   If  you  can figure out the formula for the number of rows, you
  957. X        //   deserve a raise!!!
  958. X        //
  959. X        xv_set(gwindow->dir_list,
  960. X            PANEL_LIST_WIDTH,                width - 30,
  961. X            PANEL_LIST_DISPLAY_ROWS,        (int) ((height - 61.69) / 18.91) + 1,
  962. X            NULL);
  963. X
  964. X        //
  965. X        //   Ok,  we  have resized the list. Now relocate the quit or dismiss button if
  966. X        //   it is present.
  967. X        //
  968. X        if (gwindow->dir_quit)
  969. X            xv_set(gwindow->dir_quit,
  970. X                XV_X,                            width - 10 - (gwindow->parent ? 69 : 47),
  971. X                NULL);
  972. X    }
  973. }
  974. X
  975. X
  976. //***************************************************************************
  977. // int GWList::open(Response *resp)
  978. // PURPOSE:
  979. //   This will create a window with a panel at the top and a scrolling list
  980. //   at the bottom.  The panel will be empty.
  981. //   The only special thing that is taken care of is that when there is no
  982. //   parent, the window will be a real window, while if there is a parent,
  983. //   the window will be a command window.
  984. //
  985. int GWList::open(Response *resp)
  986. {
  987. X    info = resp;
  988. X    if (!parent)
  989. X    {
  990. X        //
  991. X        // This is the main window
  992. X        //
  993. X        char version[200];
  994. X        sprintf(version, "XvGopher %s.  Root Directory", VERSION);
  995. X        frame = (Frame) xv_create(NULL, FRAME,
  996. X            XV_WIDTH,                    WINDOW_WIDTH,
  997. X            XV_HEIGHT,                    WINDOW_HEIGHT,
  998. X            FRAME_LABEL,                version,
  999. X            NULL);
  1000. X        panel = (Panel) xv_create(frame, PANEL,
  1001. X            NULL);
  1002. X        assign_icon(frame);
  1003. X
  1004. X        //
  1005. X        // The main window has a quit button
  1006. X        //
  1007. X        dir_quit = xv_create(panel, PANEL_BUTTON,
  1008. X            XV_X,                        468,    // It will be relocated anyway...
  1009. X            XV_Y,                        8,
  1010. X            PANEL_LABEL_STRING,            "Quit",
  1011. X            PANEL_NOTIFY_PROC,            quit_proc,
  1012. X            XV_KEY_DATA,                KEY_GWINDOW, this,
  1013. X            NULL);
  1014. X    }
  1015. X    else
  1016. X    {
  1017. X        //
  1018. X        // We are creating a child window
  1019. X        //
  1020. X        compute_location(WINDOW_WIDTH, WINDOW_HEIGHT);
  1021. X        frame = xv_create(parent, FRAME_CMD,
  1022. X            XV_X,                        next_x,
  1023. X            XV_Y,                        next_y,
  1024. X            XV_WIDTH,                    WINDOW_WIDTH,
  1025. X            XV_HEIGHT,                    WINDOW_HEIGHT,
  1026. X            FRAME_LABEL,                info->get_title(),
  1027. X            FRAME_CMD_PIN_STATE,        FRAME_CMD_PIN_IN,
  1028. X            FRAME_DONE_PROC,            done_proc,
  1029. X            FRAME_SHOW_RESIZE_CORNER,    TRUE,
  1030. X            NULL);
  1031. X        panel = (Panel) xv_get(frame, FRAME_CMD_PANEL);
  1032. X
  1033. X        //
  1034. X        // Child windows have a close button
  1035. X        //
  1036. X        dir_quit = xv_create(panel, PANEL_BUTTON,
  1037. X            XV_X,                        468,    // It will be relocated anyway...
  1038. X            XV_Y,                        8,
  1039. X            PANEL_LABEL_STRING,            "Dismiss",
  1040. X            PANEL_NOTIFY_PROC,            quit_proc,
  1041. X            XV_KEY_DATA,                KEY_GWINDOW, this,
  1042. X            NULL);
  1043. X    }
  1044. X
  1045. X    //
  1046. X    //   Now  some  things  which  need  to  be  set for both FRAMEs and
  1047. X    //   FRAME_CMDs
  1048. X    //
  1049. X    xv_set(frame,
  1050. X        FRAME_SHOW_FOOTER,                TRUE,
  1051. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  1052. X        FRAME_MIN_SIZE,                    280, 118,
  1053. X        FRAME_MAX_SIZE,                    0, 0,
  1054. X        WIN_EVENT_PROC,                    frame_event,
  1055. X        WIN_CONSUME_EVENTS,
  1056. X                WIN_NO_EVENTS,
  1057. X                WIN_RESIZE,
  1058. X                NULL,
  1059. X        NULL);
  1060. X
  1061. X    //
  1062. X    // Create the scrolling list.  Make it so that 0 or 1 rows can be selected.
  1063. X    //
  1064. X    dir_list = (Panel_item) xv_create(panel, PANEL_LIST,
  1065. X        XV_X,                            8,
  1066. X        XV_Y,                            36,
  1067. X        PANEL_LIST_WIDTH,                500,
  1068. X        PANEL_LIST_DISPLAY_ROWS,        15,
  1069. X        PANEL_NOTIFY_PROC,                list_notify,
  1070. X        PANEL_READ_ONLY,                TRUE,
  1071. X        PANEL_CHOOSE_ONE,                TRUE,
  1072. X        PANEL_CHOOSE_NONE,                TRUE,
  1073. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  1074. X        NULL);
  1075. X
  1076. X    return OK;
  1077. }
  1078. X
  1079. X
  1080. //***************************************************************************
  1081. // void GWList::list_notify(Panel_item item, char *, caddr_t cd, Panel_list_op op, Event *event, int row)
  1082. //   This is called when the mouse is clicked in the scrolling list.
  1083. //   We will determine if this is a double click or not.  If it is,
  1084. //   we need to create a new window to display the data.
  1085. //
  1086. void GWList::list_notify(Panel_item item, char *, caddr_t cd, Panel_list_op op, Event *event, int row)
  1087. {
  1088. X    static long        prev_click_time = 0;
  1089. X    static int        previous_row = -1;
  1090. X    long            click_time = event->ie_time.tv_sec * 1000 +
  1091. X                                 event->ie_time.tv_usec / 1000;
  1092. X    GWList            *gwindow = (GWList *) xv_get(item, XV_KEY_DATA, KEY_GWINDOW);
  1093. X
  1094. X    if (op == 0)
  1095. X    {
  1096. X        //
  1097. X        // The currently selected row was deselected.
  1098. X        //
  1099. X        gwindow->current_selected = -1;
  1100. X        gwindow->row_deselect(row, (Response *) cd);
  1101. X    }
  1102. X    else
  1103. X    {
  1104. X        //
  1105. X        // A new row was selected.
  1106. X        //
  1107. X        gwindow->current_selected = row;
  1108. X        gwindow->row_select(row, (Response *) cd);
  1109. X    }
  1110. X
  1111. X    if (row == previous_row)
  1112. X    {
  1113. X        //
  1114. X        // Check if this is a double click
  1115. X        //
  1116. X        if (click_time - prev_click_time < double_click_timeout)
  1117. X        {
  1118. X            //
  1119. X            // It is.  Start a new window.
  1120. X            //
  1121. X            Response    *r = new Response((Response *) cd);
  1122. X            GWindow    *sub;
  1123. X            if (preferences.get_remove_children())
  1124. X                sub = CreateWindow(r, gwindow->frame);
  1125. X            else
  1126. X                sub = CreateWindow(r, !gwindow->parent ? gwindow->frame : gwindow->parent);
  1127. X
  1128. X            prev_click_time = 0;
  1129. X            previous_row = -1;
  1130. X
  1131. X            //
  1132. X            // Make sure that the current item is now selected.
  1133. X            // It can happen that the user double clicked on an item which was
  1134. X            // not yet selected.  The first click will selected and the second
  1135. X            // click will deselect it.  After the second click, we will fall through
  1136. X            // to this point, so now we want to select the row again.
  1137. X            xv_set(item, PANEL_LIST_SELECT, row, TRUE, NULL);
  1138. X            gwindow->row_select(row, (Response *) cd);
  1139. X            return;
  1140. X        }
  1141. X    }
  1142. X    previous_row = row;
  1143. X    prev_click_time = click_time;
  1144. }
  1145. X
  1146. X
  1147. static unsigned short icon_bits[] = {
  1148. #include "icons/gopher.icon"
  1149. };
  1150. static unsigned short icon_mask_bits[] = {
  1151. #include "icons/gopher.icon.mask"
  1152. };
  1153. X
  1154. //***************************************************************************
  1155. // void GWList::assign_icon(Frame frame)
  1156. //
  1157. void GWList::assign_icon(Frame frame)
  1158. {
  1159. X    //
  1160. X    //   The main frame needs an icon. Give it a good one!
  1161. X    //
  1162. X    Icon            ic;
  1163. X    Server_image    icon, icon_mask;
  1164. X
  1165. X    icon = (Server_image) xv_create(NULL, SERVER_IMAGE,
  1166. X        XV_WIDTH,                    64,
  1167. X        XV_HEIGHT,                    64,
  1168. X        SERVER_IMAGE_BITS,            icon_bits,
  1169. X        NULL);
  1170. X    icon_mask = (Server_image) xv_create(NULL, SERVER_IMAGE,
  1171. X        XV_WIDTH,                    64,
  1172. X        XV_HEIGHT,                    64,
  1173. X        SERVER_IMAGE_BITS,            icon_mask_bits,
  1174. X        NULL);
  1175. X    ic = (Icon) xv_create(frame, ICON,
  1176. X        ICON_IMAGE,                    icon,
  1177. X        ICON_MASK_IMAGE,            icon_mask,
  1178. X        NULL);
  1179. X    xv_set(frame,
  1180. X        FRAME_ICON,                    ic,
  1181. X        NULL);
  1182. }
  1183. X
  1184. X
  1185. //***************************************************************************
  1186. // void GWList::row_deselect(int, Response *)
  1187. //
  1188. void GWList::row_deselect(int, Response *)
  1189. {
  1190. }
  1191. X
  1192. X
  1193. //***************************************************************************
  1194. // void GWList::row_select(int, Response *)
  1195. //
  1196. void GWList::row_select(int, Response *)
  1197. {
  1198. }
  1199. X
  1200. X
  1201. //***************************************************************************
  1202. // void GWList::show_item_info_proc(Menu, Menu_item mi)
  1203. //   Create a little popup which displays the information about the currently
  1204. //   selected item.
  1205. //
  1206. void GWList::show_item_info_proc(Menu, Menu_item mi)
  1207. {
  1208. X    GWList        *gwindow = (GWList *) xv_get(mi, XV_KEY_DATA, KEY_GWINDOW);
  1209. X
  1210. X    GWInfo        *list = new GWInfo(gwindow->frame);
  1211. X    if (gwindow->current_selected == -1)
  1212. X    {
  1213. X        //
  1214. X        // No row is selected.  We will assume we want to display info
  1215. X        // about the window itself.
  1216. X        //
  1217. X        list->open(new Response(gwindow->info));
  1218. X    }
  1219. X    else
  1220. X    {
  1221. X        //
  1222. X        // Some row was selected.  Display info about this item.
  1223. X        //
  1224. X        Response        *r;
  1225. X        r = (Response *) xv_get(gwindow->dir_list, PANEL_LIST_CLIENT_DATA, gwindow->current_selected);
  1226. X        list->open(r);
  1227. X    }
  1228. }
  1229. SHAR_EOF
  1230. chmod 0664 GWList.cc ||
  1231. echo 'restore of GWList.cc failed'
  1232. Wc_c="`wc -c < 'GWList.cc'`"
  1233. test 8870 -eq "$Wc_c" ||
  1234.     echo 'GWList.cc: original size 8870, current size' "$Wc_c"
  1235. fi
  1236. # ============= GWPref.cc ==============
  1237. if test -f 'GWPref.cc' -a X"$1" != X"-c"; then
  1238.     echo 'x - skipping GWPref.cc (File already exists)'
  1239. else
  1240. echo 'x - extracting GWPref.cc (Text)'
  1241. sed 's/^X//' << 'SHAR_EOF' > 'GWPref.cc' &&
  1242. //
  1243. // GWPref.cc
  1244. //
  1245. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1246. //       (See the COPYRIGHT file for more Copyright information)
  1247. //
  1248. // Implementation of the GWPref class
  1249. //
  1250. #include "xvgopher.h"
  1251. #include "GWPref.h"
  1252. #include "Preferences.h"
  1253. X
  1254. GWPref    *gwpref;
  1255. X
  1256. X
  1257. //***************************************************************************
  1258. // GWPref::GWpref(Frame par)
  1259. //
  1260. GWPref::GWPref(Frame par)
  1261. {
  1262. X    parent = par;
  1263. }
  1264. X
  1265. X
  1266. //***************************************************************************
  1267. // GWPref::~GWpref()
  1268. //
  1269. GWPref::~GWPref()
  1270. {
  1271. }
  1272. X
  1273. X
  1274. //***************************************************************************
  1275. // void GWPref::done_proc(Frame frame)
  1276. //   This gets called whenever a command frame is destroyed.  In the case
  1277. //   of the preferences window, we only need to hide the window.
  1278. //
  1279. void GWPref::done_proc(Frame frame)
  1280. {
  1281. X    xv_set(frame,
  1282. X        XV_SHOW,                        FALSE,
  1283. X        NULL);
  1284. }
  1285. X
  1286. X
  1287. //***************************************************************************
  1288. // int GWPref::open(Response *)
  1289. //   Create the preferences window.
  1290. //
  1291. int GWPref::open(Response *)
  1292. {
  1293. X    compute_location(600, 500);
  1294. X    frame = (Frame) xv_create(parent, FRAME_CMD,
  1295. X        XV_X,                            next_x,
  1296. X        XV_Y,                            next_y,
  1297. X        XV_WIDTH,                        447,
  1298. X        XV_HEIGHT,                        248,
  1299. X        FRAME_LABEL,                    "Preferences",
  1300. X        FRAME_CMD_PIN_STATE,            FRAME_CMD_PIN_OUT,
  1301. X        FRAME_SHOW_RESIZE_CORNER,        FALSE,
  1302. X        XV_SHOW,                        FALSE,
  1303. X        FRAME_SHOW_FOOTER,                FALSE,
  1304. X        FRAME_DONE_PROC,                (void (*)(Frame)) done_proc,
  1305. X        XV_KEY_DATA,                    KEY_GWINDOW,    this,
  1306. X        NULL);
  1307. X    panel = (Panel) xv_get(frame, FRAME_CMD_PANEL);
  1308. X
  1309. X    int    value = preferences.get_popup_bookmarks() * 2 |
  1310. X                preferences.get_remove_children();
  1311. X
  1312. X    choices = (Panel_item) xv_create(panel, PANEL_CHECK_BOX,
  1313. X        XV_X,                            16,
  1314. X        XV_Y,                            8,
  1315. X        PANEL_LAYOUT,                    PANEL_VERTICAL,
  1316. X        PANEL_CHOICE_STRINGS,            "Remove all child windows when parent is unpinned",
  1317. X                                        "Popup Bookmarks at startup",
  1318. X                                        NULL,
  1319. X        PANEL_VALUE,                    value,
  1320. X        NULL);
  1321. X
  1322. X    play = (Panel_item) xv_create(panel, PANEL_TEXT,
  1323. X        XV_X,                            16,
  1324. X        XV_Y,                            76,
  1325. X        PANEL_VALUE_DISPLAY_LENGTH,        30,
  1326. X        PANEL_VALUE_STORED_LENGTH,        80,
  1327. X        PANEL_LABEL_STRING,                "Sound play command:",
  1328. X        NULL);
  1329. X    image = (Panel_item) xv_create(panel, PANEL_TEXT,
  1330. X        XV_X,                            14,
  1331. X        XV_Y,                            101,
  1332. X        PANEL_VALUE_DISPLAY_LENGTH,        30,
  1333. X        PANEL_VALUE_STORED_LENGTH,        80,
  1334. X        PANEL_LABEL_STRING,                "Image view command:",
  1335. X        NULL);
  1336. X    telnet = (Panel_item) xv_create(panel, PANEL_TEXT,
  1337. X        XV_X,                            48,
  1338. X        XV_Y,                            126,
  1339. X        PANEL_VALUE_DISPLAY_LENGTH,        30,
  1340. X        PANEL_VALUE_STORED_LENGTH,        80,
  1341. X        PANEL_LABEL_STRING,                "Telnet command:",
  1342. X        NULL);
  1343. X    print = (Panel_item) xv_create(panel, PANEL_TEXT,
  1344. X        XV_X,                            59,
  1345. X        XV_Y,                            151,
  1346. X        PANEL_VALUE_DISPLAY_LENGTH,        30,
  1347. X        PANEL_VALUE_STORED_LENGTH,        80,
  1348. X        PANEL_LABEL_STRING,                "Print command:",
  1349. X        NULL);
  1350. X    mail = (Panel_item) xv_create(panel, PANEL_TEXT,
  1351. X        XV_X,                            62,
  1352. X        XV_Y,                            176,
  1353. X        PANEL_VALUE_DISPLAY_LENGTH,        30,
  1354. X        PANEL_VALUE_STORED_LENGTH,        80,
  1355. X        PANEL_LABEL_STRING,                "Mail command:",
  1356. X        NULL);
  1357. X
  1358. X    xv_create(panel, PANEL_BUTTON,
  1359. X        XV_X,                            197,
  1360. X        XV_Y,                            208,
  1361. X        PANEL_LABEL_STRING,                "Apply",
  1362. X        XV_KEY_DATA,                    KEY_GWINDOW, this,
  1363. X        PANEL_NOTIFY_PROC,                apply,
  1364. X        NULL);
  1365. X
  1366. X    return OK;
  1367. }
  1368. X
  1369. X
  1370. //***************************************************************************
  1371. // void GWPref::show()
  1372. //
  1373. void GWPref::show()
  1374. {
  1375. X    xv_set(mail,
  1376. X        PANEL_VALUE,                    preferences.get_mail_filter(),
  1377. X        NULL);
  1378. X    xv_set(print,
  1379. X        PANEL_VALUE,                    preferences.get_print_filter(),
  1380. X        NULL);
  1381. X    xv_set(telnet,
  1382. X        PANEL_VALUE,                    preferences.get_telnet_command(),
  1383. X        NULL);
  1384. X    xv_set(image,
  1385. X        PANEL_VALUE,                    preferences.get_image_filter(),
  1386. X        NULL);
  1387. X    xv_set(play,
  1388. X        PANEL_VALUE,                    preferences.get_play_filter(),
  1389. X        NULL);
  1390. X    xv_set(frame,
  1391. X        XV_SHOW,                        TRUE,
  1392. X        NULL);
  1393. }
  1394. X
  1395. X
  1396. //***************************************************************************
  1397. // void GWPref::apply(Panel_item item, Event *)
  1398. //   Read the changes made to the preferences panel and put them in our
  1399. //   database.
  1400. //
  1401. void GWPref::apply(Panel_item item, Event *)
  1402. {
  1403. X    GWPref    *gw = (GWPref *) xv_get(item, XV_KEY_DATA, KEY_GWINDOW);
  1404. X
  1405. X    int    value = (int) xv_get(gw->choices, PANEL_VALUE);
  1406. X    preferences.set_remove_children(value & 1);
  1407. X    preferences.set_popup_bookmarks(value & 2);
  1408. X
  1409. X    preferences.set_mail_filter((char *) xv_get(gw->mail, PANEL_VALUE));
  1410. X    preferences.set_print_filter((char *) xv_get(gw->print, PANEL_VALUE));
  1411. X    preferences.set_play_filter((char *) xv_get(gw->play, PANEL_VALUE));
  1412. X    preferences.set_image_filter((char *) xv_get(gw->image, PANEL_VALUE));
  1413. X    preferences.set_telnet_command((char *) xv_get(gw->telnet, PANEL_VALUE));
  1414. X
  1415. X    //
  1416. X    // Finally, remove the window.
  1417. X    //
  1418. X    xv_set(gw->frame,
  1419. X        XV_SHOW,                        FALSE,
  1420. X        NULL);
  1421. }
  1422. X
  1423. X
  1424. SHAR_EOF
  1425. chmod 0644 GWPref.cc ||
  1426. echo 'restore of GWPref.cc failed'
  1427. Wc_c="`wc -c < 'GWPref.cc'`"
  1428. test 4701 -eq "$Wc_c" ||
  1429.     echo 'GWPref.cc: original size 4701, current size' "$Wc_c"
  1430. fi
  1431. # ============= GWSound.cc ==============
  1432. if test -f 'GWSound.cc' -a X"$1" != X"-c"; then
  1433.     echo 'x - skipping GWSound.cc (File already exists)'
  1434. else
  1435. echo 'x - extracting GWSound.cc (Text)'
  1436. sed 's/^X//' << 'SHAR_EOF' > 'GWSound.cc' &&
  1437. //
  1438. // GWSound.cc
  1439. //
  1440. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1441. //       (See the COPYRIGHT file for more Copyright information)
  1442. //
  1443. // Implementation of the GWSound class
  1444. //
  1445. #include "GWSound.h"
  1446. #include "xvgopher.h"
  1447. X
  1448. X
  1449. //***************************************************************************
  1450. // GWSound::GWSound(Frame par)
  1451. //
  1452. GWSound::GWSound(Frame par) : GWDownload(par, GWDownload::BINARY, "Play", preferences.get_play_filter())
  1453. {
  1454. }
  1455. SHAR_EOF
  1456. chmod 0644 GWSound.cc ||
  1457. echo 'restore of GWSound.cc failed'
  1458. Wc_c="`wc -c < 'GWSound.cc'`"
  1459. test 469 -eq "$Wc_c" ||
  1460.     echo 'GWSound.cc: original size 469, current size' "$Wc_c"
  1461. fi
  1462. # ============= GWTelnet.cc ==============
  1463. if test -f 'GWTelnet.cc' -a X"$1" != X"-c"; then
  1464.     echo 'x - skipping GWTelnet.cc (File already exists)'
  1465. else
  1466. echo 'x - extracting GWTelnet.cc (Text)'
  1467. sed 's/^X//' << 'SHAR_EOF' > 'GWTelnet.cc' &&
  1468. //
  1469. // GWTelnet.cc
  1470. //
  1471. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1472. //       (See the COPYRIGHT file for more Copyright information)
  1473. //
  1474. // Implementation of the GWTelnet class
  1475. //
  1476. #include "GWTelnet.h"
  1477. #include "xvgopher.h"
  1478. #include <fcntl.h>
  1479. #include <unistd.h>
  1480. X
  1481. X
  1482. //***************************************************************************
  1483. // GWTelnet::GWTelnet(Frame par)
  1484. //
  1485. GWTelnet::GWTelnet(Frame par)
  1486. {
  1487. X    parent = par;
  1488. }
  1489. X
  1490. X
  1491. //***************************************************************************
  1492. // int GWTelnet::open(Response *resp)
  1493. // PURPOSE:
  1494. //   This is called when a telnet record has been received.  We need to start a
  1495. //   terminal emulator and start telnet in it (to the correct host...)
  1496. //
  1497. int GWTelnet::open(Response *resp)
  1498. {
  1499. X    char    command[2000];
  1500. X    char    new_title[2000];
  1501. X    int        port;
  1502. X
  1503. X    info = resp;
  1504. X    if (info->get_port() == 0)
  1505. X        port = 23;            // There seems to be a problem with Mark Boyns.  He didn't want to fix this in the gopher files!
  1506. X    else
  1507. X        port = info->get_port();
  1508. X    if (*info->get_command())
  1509. X        sprintf(new_title, "%s (login as %s)", info->get_title(), info->get_command());
  1510. X    else
  1511. X        strcpy(new_title, info->get_title());
  1512. X    sprintf(command, preferences.get_telnet_command(),
  1513. X                new_title,
  1514. X                info->get_server(),
  1515. X                port,
  1516. X                info->get_type());
  1517. X    system(command);
  1518. X    return OK;
  1519. }
  1520. X
  1521. X
  1522. SHAR_EOF
  1523. chmod 0644 GWTelnet.cc ||
  1524. echo 'restore of GWTelnet.cc failed'
  1525. Wc_c="`wc -c < 'GWTelnet.cc'`"
  1526. test 1331 -eq "$Wc_c" ||
  1527.     echo 'GWTelnet.cc: original size 1331, current size' "$Wc_c"
  1528. fi
  1529. # ============= GWindow.cc ==============
  1530. if test -f 'GWindow.cc' -a X"$1" != X"-c"; then
  1531.     echo 'x - skipping GWindow.cc (File already exists)'
  1532. else
  1533. echo 'x - extracting GWindow.cc (Text)'
  1534. sed 's/^X//' << 'SHAR_EOF' > 'GWindow.cc' &&
  1535. //
  1536. // GWindow.cc
  1537. //
  1538. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1539. //       (See the COPYRIGHT file for more Copyright information)
  1540. //
  1541. // Implementation of the Window class
  1542. //
  1543. #include "GWBinary.h"
  1544. #include "GWDirectory.h"
  1545. #include "GWBookmarks.h"
  1546. #include "GWFile.h"
  1547. #include "GWIndex.h"
  1548. #include "GWSound.h"
  1549. #include "GWImage.h"
  1550. #include "GWTelnet.h"
  1551. #include "Connection.h"
  1552. #include <unistd.h>
  1553. #include <xview/notice.h>
  1554. #include "xvgopher.h"
  1555. #include "icons.h"
  1556. #include "cursor.h"
  1557. X
  1558. int GWindow::next_x = 0;
  1559. int GWindow::next_y = 0;
  1560. X
  1561. X
  1562. //***************************************************************************
  1563. // char *good_strtok(char *str, char *term)
  1564. // PURPOSE:
  1565. //   This is a replacement for the standard strtok() which has a MAJOR
  1566. //   problem when it comes to having multiple delimiters in a row.
  1567. //   This one will return after EVERY terminator that is found.
  1568. //
  1569. char *good_strtok(char *str, char *term)
  1570. {
  1571. X    static char    *string;
  1572. X    if (str)
  1573. X    {
  1574. X        string = str;
  1575. X    }
  1576. X
  1577. X    if (string == NULL || *string == '\0')
  1578. X        return NULL;
  1579. X
  1580. X    char *p = string;
  1581. X    while (*string && strchr(term, *string) == NULL)
  1582. X        string++;
  1583. X    if (*string)
  1584. X        *string++ = '\0';
  1585. X    return p;
  1586. }
  1587. X
  1588. X
  1589. //***************************************************************************
  1590. // GWindow::GWindow()
  1591. //
  1592. GWindow::GWindow()
  1593. {
  1594. X    gopher = NULL;
  1595. X    frame = parent = NULL;
  1596. X    panel = NULL;
  1597. X    info = NULL;
  1598. }
  1599. X
  1600. X
  1601. //***************************************************************************
  1602. // GWindow::~GWindow()
  1603. //
  1604. GWindow::~GWindow()
  1605. {
  1606. X    if (gopher)
  1607. X        delete gopher;
  1608. X    if (info)
  1609. X        delete info;
  1610. X
  1611. X    //
  1612. X    // If this is the parent of all windows, also delete the bookmarks so that
  1613. X    // all changes get written to disk.
  1614. X    //
  1615. X    if (!parent)
  1616. X        delete bookmarks;
  1617. X
  1618. X    xv_destroy_safe(frame);
  1619. }
  1620. X
  1621. X
  1622. //***************************************************************************
  1623. // void GWindow::main_loop()
  1624. // PURPOSE:
  1625. //    This is the main loop for the windowing program.
  1626. //    When we return from this, the program should terminate
  1627. //
  1628. void GWindow::main_loop()
  1629. {
  1630. X    xv_main_loop(frame);
  1631. }
  1632. X
  1633. X
  1634. //***************************************************************************
  1635. // void GWindow::display()
  1636. // PURPOSE:
  1637. //    Display information from the gopher server in our window
  1638. //
  1639. void GWindow::display()
  1640. {
  1641. X    frame_unbusy(frame);
  1642. }
  1643. X
  1644. X
  1645. //***************************************************************************
  1646. // int GWindow::open(Response *resp)
  1647. //
  1648. int GWindow::open(Response *resp)
  1649. {
  1650. X    resp = resp;
  1651. X    printf("ERROR!!!  THIS SHOULD NEVER HAPPEN!\n");
  1652. X    exit(42);
  1653. X    return 0;
  1654. }
  1655. X
  1656. X
  1657. //***************************************************************************
  1658. // void GWindow::quit_proc(Frame frame, Event *event)
  1659. // PURPOS:
  1660. //   This gets called when the user presses 'q' in a window.
  1661. //
  1662. void GWindow::quit_proc(Frame frame, Event *event)
  1663. {
  1664. X    event = event;
  1665. X    GWindow    *win = (GWindow *) xv_get(frame, XV_KEY_DATA, KEY_GWINDOW);
  1666. X    delete win;
  1667. X    xv_destroy_safe(frame);
  1668. }
  1669. X
  1670. X
  1671. //***************************************************************************
  1672. // void GWindow::done_proc(Frame frame)
  1673. // PURPOSE:
  1674. //   This gets called whenever a command frame is destroyed.  We need to
  1675. //   clean up the associated GWindow structure.  Since we want all children
  1676. //   to go away as well, we will call this function recursively on our subframes.
  1677. //
  1678. void GWindow::done_proc(Frame frame)
  1679. {
  1680. X    if (!frame)
  1681. X        return;
  1682. X    GWindow    *win = (GWindow *) xv_get(frame, XV_KEY_DATA, KEY_GWINDOW);
  1683. X    Frame    subframe = (Frame) xv_get(frame, FRAME_NTH_SUBFRAME, 1);
  1684. X    done_proc(subframe);
  1685. X    delete win;
  1686. X    xv_destroy_safe(frame);
  1687. }
  1688. X
  1689. X
  1690. //***************************************************************************
  1691. // void GWindow::status(char *str)
  1692. // PURPOSE:
  1693. //   Display an informative message in the footer of the window
  1694. //
  1695. void GWindow::status(char *str)
  1696. {
  1697. X    xv_set(frame,
  1698. X        FRAME_LEFT_FOOTER,                str,
  1699. X        NULL);
  1700. }
  1701. X
  1702. X
  1703. //***************************************************************************
  1704. // void GWindow::compute_location(int width, int height)
  1705. // PURPOSE:
  1706. //   Compute the location of the next window.  The size of the next window is
  1707. //   given so that we can make sure that the whole window is displayed on the
  1708. //   screen.
  1709. //
  1710. void GWindow::compute_location(int width, int height)
  1711. {
  1712. X    GWindow    * gwindow = (GWindow *) xv_get(parent, XV_KEY_DATA, KEY_GWINDOW);
  1713. X    static int    first_time = 2;
  1714. X
  1715. X    if (!gwindow->parent && first_time)
  1716. X    {
  1717. X        //
  1718. X        // The current window is the second window of the program.  This is because
  1719. X        // our parent doesn't have a parent.
  1720. X        //
  1721. X        next_x = (int) xv_get(parent, XV_X);
  1722. X        next_y = (int) xv_get(parent, XV_Y);
  1723. X        first_time--;
  1724. X    }
  1725. X
  1726. X    //
  1727. X    // We now have next_x and next_y to work with as the location of the previous window.
  1728. X    // Now we need to increment them and possibly wrap them if the window will not fit
  1729. X    // on the screen.
  1730. X    //
  1731. X    next_x += 10;
  1732. X    next_y += 25;
  1733. X
  1734. X    //
  1735. X    // Get the size of the screen.  We will use the parent frame for this since
  1736. X    // we are not sure that our frame has been initialized, yet.
  1737. X    //
  1738. X    Display    *dpy = (Display *) xv_get(parent, XV_DISPLAY);
  1739. X    int screen_width = DisplayWidth(dpy, DefaultScreen(dpy));
  1740. X    int screen_height = DisplayHeight(dpy, DefaultScreen(dpy));
  1741. X    if (next_x + width + 20 > screen_width)
  1742. X        next_x = 0;
  1743. X    if (next_y + height + 40 > screen_height)
  1744. X        next_y = 0;
  1745. }
  1746. X
  1747. X
  1748. //***************************************************************************
  1749. // GWindow *CreateWindow(Response *resp, Frame par)
  1750. // PURPOSE:
  1751. //   This function will create a new window which will display the
  1752. //   data specified in the arguments correctly.
  1753. //
  1754. GWindow *CreateWindow(Response *resp, Frame par)
  1755. {
  1756. X    GWindow    *gw;
  1757. X
  1758. X    switch (resp->get_type())
  1759. X    {
  1760. X        case GOPHER_FILE:
  1761. X            gw = new GWFile(par);
  1762. X            break;
  1763. X        case GOPHER_DIRECTORY:
  1764. X            gw = new GWDirectory(par);
  1765. X            break;
  1766. X        case GOPHER_SPECIAL:
  1767. X            gw = new GWDirectory(par);
  1768. X            break;
  1769. X        case GOPHER_SOUND:
  1770. X            gw = new GWSound(par);
  1771. X            break;
  1772. X        case GOPHER_BIN:
  1773. X            gw = new GWBinary(par);
  1774. X            break;
  1775. X        case GOPHER_CSO:
  1776. X        case GOPHER_ERROR:
  1777. X            xv_create(par, NOTICE,
  1778. X                NOTICE_MESSAGE_STRINGS,        "XvGopher currently doesn not support this",
  1779. X                                            NULL,
  1780. X                NOTICE_BUTTON_YES,            "Bummer",
  1781. X                NOTICE_BLOCK_THREAD,        TRUE,
  1782. X                NOTICE_LOCK_SCREEN,            TRUE,
  1783. X                XV_SHOW,                    TRUE,
  1784. X                NULL);
  1785. X            return NULL;
  1786. X            break;
  1787. X        case GOPHER_BINHEX:
  1788. X        case GOPHER_DOS:
  1789. X        case GOPHER_UU:
  1790. X            gw = new GWBinary(par);
  1791. X            break;
  1792. X        case GOPHER_INDEX:
  1793. X            gw = new GWIndex(par);
  1794. X            break;
  1795. X        case GOPHER_TELNET:
  1796. X            gw = new GWTelnet(par);
  1797. X            break;
  1798. X        case GOPHER_IMAGE:
  1799. X            gw = new GWImage(par);
  1800. X            break;
  1801. X        case GOPHER_REDUNDANT:
  1802. X        default:
  1803. X            printf("Sorry, '%c' not implemented, yet!\n", resp->get_type());
  1804. X            return NULL;
  1805. X    }
  1806. X    if (gw->open(resp) == OK)
  1807. X        return gw;
  1808. X    else
  1809. X    {
  1810. X        delete gw;
  1811. X        return NULL;
  1812. X    }
  1813. }
  1814. X
  1815. X
  1816. //***************************************************************************
  1817. // void GWindow::nothing_found()
  1818. // PURPOSE:
  1819. //   This function will create a new window which will display the
  1820. //   data specified in the arguments correctly.
  1821. //
  1822. void GWindow::nothing_found()
  1823. {
  1824. X    xv_create(parent, NOTICE,
  1825. X        NOTICE_BLOCK_THREAD,            TRUE,
  1826. X        NOTICE_LOCK_SCREEN,                TRUE,
  1827. X        NOTICE_MESSAGE_STRINGS,            "Nothing was found!", NULL,
  1828. X        NOTICE_BUTTON_YES,                "Bummer",
  1829. X        XV_SHOW,                        TRUE,
  1830. X        NULL);
  1831. X    delete this;
  1832. }
  1833. X
  1834. X
  1835. //***************************************************************************
  1836. // void GWindow::list_full()
  1837. //   This will create a popup telling the user that the scrolling list is full.
  1838. //   I have imposed a limit because xview will hang when a scrolling list gets
  1839. //   more than a couple thousand entries in it.
  1840. //
  1841. void GWindow::list_full()
  1842. {
  1843. X    xv_create(frame, NOTICE,
  1844. X        NOTICE_MESSAGE_STRINGS,        "The scrolling list is full.  Sorry",
  1845. X                                    NULL,
  1846. X        NOTICE_BUTTON_YES,            "Oh well",
  1847. X        NOTICE_BLOCK_THREAD,        TRUE,
  1848. X        NOTICE_LOCK_SCREEN,            TRUE,
  1849. X        XV_SHOW,                    TRUE,
  1850. X        NULL);
  1851. }
  1852. X
  1853. X
  1854. SHAR_EOF
  1855. chmod 0664 GWindow.cc ||
  1856. echo 'restore of GWindow.cc failed'
  1857. Wc_c="`wc -c < 'GWindow.cc'`"
  1858. test 7751 -eq "$Wc_c" ||
  1859.     echo 'GWindow.cc: original size 7751, current size' "$Wc_c"
  1860. fi
  1861. true || echo 'restore of Gopher.cc failed'
  1862. echo End of part 2, continue with part 3
  1863. exit 0
  1864.